package work;

public class test4 {
    public static final Object lock = new Object();
    private static int count = 1;
    private static char ch = 'A';

    public static void main(String[] args) {
        Thread numThread = new Thread(() -> {
            while (count <= 52) {
                synchronized (lock) {
                    System.out.print(count++);
                    System.out.print(count++);
                    lock.notify();
                    try {
                        if (count <= 52) {
                            lock.wait();
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        Thread charThread = new Thread(() -> {
            while (ch <= 'Z') {
                synchronized (lock) {
                    System.out.print(ch++);
                    lock.notify();
                    try {
                        if (ch <= 'Z') {
                            lock.wait();
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        numThread.start();
        charThread.start();
    }
}
